
/***
 * 建造车模型
 */
class Builder {
    car = new Car()
    /***
     * 座椅
     */
    setSeat(){
        
    }
    /***
     * 形式
     */
    setMode(){
        
    }
    /***
     * 品牌
     */
    setBrand(){
        
    }
    createCar(){
        console.log("生产汽车：",this.car.mode,this.car.seat,this.car.brand)
        return this.car
    }
}
/***
 * 车有多部分组成
 */
class Car {
    setSeat(seat){
        this.seat = seat
    }
    setMode(mode){
        this.mode = mode
    }

    setBrand(brand){
        this.brand = brand
    }
}

class BMW extends Builder{
    setSeat(){
        this.car.setSeat("真皮")
    }
    setMode(){
        this.car.setMode("燃油")
    }
    setBrand(){
        this.car.setBrand("宝马")
    }
}

class BYD extends Builder{
    setSeat(){
        this.car.setSeat("纯棉")
    }
    setMode(){
        this.car.setMode("电动")
    }
    setBrand(){
        this.car.setBrand("比亚迪")
    }
}

class Director{
    constructor(builder){
        this.builder = builder
    }
    produce(){
        this.builder.setMode()
        this.builder.setSeat()
        this.builder.setBrand()
        return this.builder.createCar()
    }
}


new Director(new BMW()).produce()


